package com.aop.mapper;

import com.aop.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * @author wzm
 * @create 2023-10-07 16:41
 * project_name:stu_sys
 */
@Mapper
public interface EmpMapper {
    //分页查询
//    @Select("select * from emp")
    List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);

    //删除
    void delete(List<Integer> ids);

    //新增
    @Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time) " +
            "values (#{username}, #{name}, #{gender}, #{image}, #{job}, #{entrydate}, #{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);

    @Select("select  id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time from emp where id=#{id}")
    Emp selectById(Integer id);

    //修改
    void update(Emp emp);

    //根据用户名和密码查询
    @Select("select id, username, password, name, gender, image, job, entrydate, dept_id, create_time, update_time from emp where username = #{username} and password = #{password}")
    Emp selectByUserNameAndPassWord(Emp emp);

    //根据部门id删除员工的方法
    @Delete("delete from emp where dept_id = #{deptId}")
    void deleteByDeptId(Integer deptId);

    //获取总记录数
   /* @Select("select count(1) from emp")
    Long count();*/

    //分页查询数据列表
   /* @Select("select * from emp limit #{begin},#{pageSize}")
    List<Emp> listByPage(Integer begin, Integer pageSize);*/
}

